import 'package:flutter/material.dart';

class EJStaticEnter extends StatefulWidget {
  EJStaticEnter({super.key, this.pageController});
  PageController? pageController;

  @override
  State<EJStaticEnter> createState() => _EJStaticEnterState();
}

class _EJStaticEnterState extends State<EJStaticEnter> {
  _goToStatisticsPage() {
    // NavigationBar
    var Page = widget.pageController!;
    Page.jumpToPage(2);
  }

  _goToCheckerPage() {
    var Page = widget.pageController!;
    Page.jumpToPage(4);
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 150,
      margin: const EdgeInsets.only(left: 15, right: 15),
      child: Row(
        children: [
          Expanded(
            child: enterView(0, 'Statistics',
                'assets/sys_imgs/EJ_statictics.png', 'Drawing History'),
          ),
          const SizedBox(width: 15),
          Expanded(
            child: enterView(1, 'Checker', 'assets/sys_imgs/EJ_checker.png',
                'Lotto Results'),
          ),
        ],
      ),
    );
  }

  Widget enterView(int index, String name, String image, String detail) {
    double imgW = 45.0;
    return GestureDetector(
      onTap: () {
        debugPrint('enter-->$index');
        if (index == 0) {
          _goToStatisticsPage();
        } else if (index == 1) {
          _goToCheckerPage();
        }
      },
      child: Container(
        decoration: BoxDecoration(
          boxShadow: [
            BoxShadow(
              color: Colors.black.withOpacity(0.2), // 阴影颜色
              spreadRadius: 1, // 扩散半径
              blurRadius: 10, // 模糊半径
              offset: Offset(0, 1), // 阴影偏移
            ),
          ],
          borderRadius: BorderRadius.all(Radius.circular(10)),
          color: Colors.white,
        ),
        margin: const EdgeInsets.only(top: 10, bottom: 10),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset(
              image,
              width: imgW,
              height: imgW,
            ),
            Text(
              name,
              style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600),
            ),
            Text(detail),
          ],
        ),
      ),
    );
  }
}
